package com.laxia;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.support.DefaultBeanNameGenerator;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @author weishuai
 * @since 2020/1/10
 */
@EnableAsync
@EnableScheduling
@ServletComponentScan
@SpringBootApplication
@EnableTransactionManagement
@ComponentScan(nameGenerator = DefaultBeanNameGenerator.class)
@Slf4j
public class LaXiaApplication {
    public static void main(String[] args) throws UnknownHostException {



        ConfigurableApplicationContext run = SpringApplication.run(LaXiaApplication.class, args);
        Environment env = run.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        String path = env.getProperty("server.servlet.context-path");
        String appName = env.getProperty("spring.application.name");
        String active  = env.getProperty("spring.profiles.active");
        log.info("\n-----------------------LaXia-Service 启动成功------------\n\t" +
                "应用名称: \t"+appName+"\n\t" +
                "启动环境: \t"+active+"\n\t" +
                "调用地址: \thttp://" + ip + ":" + port + path + "\n\t" +
                "----------------------------------------------------------");
    }
}
